﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using ModuleDALCore;
using System.Data;
namespace DAL
{
    public class LOAINHACUNGCAPDAO:DALBase
    {
        public LOAINHACUNGCAPDAO()
        {
            this.OpenConnect();
        }
        private DataTable dt;
        private string _SpName;

        public string SpName
        {
            get { return "SPLOAINHACUNGCAP"; }
            set { _SpName = value; }
        }
        public DataTable GetListLOAINHACUNGCAP()
        {
            dt = new DataTable();
            try
            {

                dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LOAINHACUNGCAP(), null), ConvertClassToArray.GetValues(new LOAINHACUNGCAP(), 0));
                return dt;
            }
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LOAINHACUNGCAP"); }
        }
        public List<LOAINHACUNGCAP> GetListLOAINHACUNGCAP(int? flag)
        {
            List<LOAINHACUNGCAP> benhnhanc = new List<LOAINHACUNGCAP>();
            dt = new DataTable();
            try
            {

                dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new LOAINHACUNGCAP(), null), ConvertClassToArray.GetValues(new LOAINHACUNGCAP(), 0));
                benhnhanc = (List<LOAINHACUNGCAP>)ConvertDatatableToList.ConvertTo<LOAINHACUNGCAP>(dt);
            }
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list LOAINHACUNGCAP"); }
            return benhnhanc;
        }
        public String CreatenewId()
        {
            try
            {
                return "LNCC" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new LOAINHACUNGCAP(), null), ConvertClassToArray.GetValues(new LOAINHACUNGCAP(), 1));

            }
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't Create new LOAINHACUNGCAP"); }
        }
        public bool INSERT(LOAINHACUNGCAP cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Insert new LOAINHACUNGCAP"); }
        }
        public bool UPDATE(LOAINHACUNGCAP cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Update  LOAINHACUNGCAP"); }
        }
        public bool DELETE(LOAINHACUNGCAP cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) == 1);

            }
			catch { return false; }//throw new InvalidExpressionException("Msg1: Can't Delete  LOAINHACUNGCAP"); }
        }
    }
}
